import java.util.Scanner;
public class demo02 {
    //冰雹数
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n=sc.nextLong();
        long max=n;
        for (long i = 1; i <= n; i++) {
            long tmp = i;
            while (tmp != 1) {
                if (tmp % 2 == 0) {
                    tmp /= 2;
                } else {
                    tmp = tmp * 3 + 1;
                }
                if (tmp > max) {
                    max = tmp;
                }
            }
        }
        System.out.println(max);
        sc.close();
    }
}
